Repository navigation
feat(pm-aggregator): outage queueing for action writes during an Access/IdP outage (#9608) - #13292
Conversation
…ss/IdP outage (#9608) The remaining slice of #1253 split 6 (design section 6): when Access verification fails (the enforcer's 401), an eligible dashboard action write from a stack-local address queues as an unverified claim instead of failing — stamped provenance: outage-queued in a dedicated store, audited before it persists, and held out of the actions store (and so out of every consumer poll and verified-authorship surface) until its claimant confirms it with a fresh verified login whose derived author matches the claim. Confirmation re-runs the published-item checks and releases the write into the actions store under the verified author; rejection is the claimant's, or the verified owner's. A 403 (a verified identity contradicting the claim) never queues; ineligible writes (muse claims, the aggregator-applied view verbs) and non-local origins keep today's refusal byte-identical. Comments are untouched (the #1253 question-4 gate). - src/outage-queue.ts: store, eligibility, stack-local check, claim matching, queue/confirm/reject core with audit-first transitions - src/server.ts: peer address threaded from Bun.serve; queue fallback on POST /api/actions and per-item in /api/actions/batch; GET /api/actions/outage-queue.json; POST .../outage-queue/confirm and .../reject behind a fresh-verified-login gate - src/config.ts: outageQueueFile (PM_AGG_OUTAGE_QUEUE_FILE, state-dir default, the break-glass precedent) - tests: unit suite (oracle section 6) + boot-based route suite + config default/env coverage
…#9608) - rejection audit assertion searched the events list by content, not position (the store lists newest-first) - the route suite points PM_METADATA_DB_PATH at its temp dir so the booted server starts in a clean venue (its default state directory does not exist there; the pre-existing boot suites fail the same way in such a venue, unrelated to this change)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8d2a00e20
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| queue: queued.record, | ||
| ...(queued.created ? {} : { deduped: true }), | ||
| }, | ||
| 202, |
There was a problem hiding this comment.
Handle queued responses in the dashboard submission clients
When an outage queues a dashboard submission, the existing client in render.ts:469–489 treats this 202 as an ordinary success and displays “sent · pending — the fleet applies it on its next pass.” The bulk client likewise treats ok: true as recorded and even tombstones snoozed cards (render.ts:3292–3311). These actions never reach the fleet until explicitly confirmed, so users are told their work will execute when it actually remains blocked indefinitely. Repository-wide searches for the new queue endpoints found no dashboard confirmation integration. Update both clients to distinguish queued claims from submitted actions and expose the required confirmation step.
Useful? React with 👍 / 👎.
| const released = await input.release({ | ||
| ...record.action, | ||
| author: input.derivedAuthor, | ||
| payload: { ...record.action.payload }, | ||
| }); |
There was a problem hiding this comment.
Serialize confirmation and rejection before releasing an action
If confirmation and rejection overlap for the same record, both can read its state as queued. While confirmation awaits its release callback, rejection can successfully persist rejected; confirmation then still inserts an executable action through actionsStore.add and only detects the conflict at the final resolve. The reject request therefore reports success while the rejected write can execute, and confirmation returns 409 despite publishing it. Serialize the entire per-record resolution operation, including release, rather than only the final queue-file update.
Useful? React with 👍 / 👎.
| const added = await actionsStore.add(action); | ||
| if (added.duplicateOf) { |
There was a problem hiding this comment.
Preserve duplicate-answer rejection on confirmation retries
When a queued answer conflicts with an existing answer, the first confirmation persists a rejected duplicate and returns 409. On retry, ActionsStore.add deduplicates by client token and returns that same rejected action with created: false, but without the top-level duplicateOf field checked here. This callback then reports success, causing the queue record to become confirmed even though its action remains rejected and will never execute. Mirror the ordinary POST route's additional check of added.action.duplicateOf on client-token replays so retries retain the rejection instead of reporting a successful release.
Useful? React with 👍 / 👎.
| const existing = await input.store.byClientToken(input.action.clientToken); | ||
| if (existing) return { record: existing, created: false }; |
There was a problem hiding this comment.
Deduplicate client tokens inside the serialized insertion
When two outage submissions with the same client token overlap, both can complete this lookup before either inserts its record. OutageQueueStore.add serializes only an unconditional push, so both requests subsequently persist distinct queue records and audit events for the same submission. Those records can be resolved independently: rejecting one still leaves the other available for confirmation, defeating the submission's idempotency and rejection semantics. Perform the token lookup and audited insertion within the same serialized operation so concurrent retries return a single queue record.
Useful? React with 👍 / 👎.
| queue: queued.record, | ||
| ...(queued.created ? {} : { deduped: true }), | ||
| }, | ||
| 202, |
There was a problem hiding this comment.
Handle queued responses in the dashboard submission clients
When an outage queues a dashboard submission, the existing client in render.ts:469��489 treats this 202 as an ordinary success and displays “sent · pending — the fleet applies it on its next pass.” The bulk client likewise treats ok: true as recorded and even tombstones snoozed cards (render.ts:3292–3311). These actions never reach the fleet until explicitly confirmed, so users are told their work will execute when it actually remains blocked indefinitely. Repository-wide searches for the new queue endpoints found no dashboard confirmation integration. Update both clients to distinguish queued claims from submitted actions and expose the required confirmation step.
Useful? React with 👍 / 👎.
Summary
The remaining slice of #9608 (#1253 split 6, design record
doc/2026-11-10T23-58-00Z_design_pm_stack_identitysection 6): outage queueing for dashboard action writes. The owner break-glass token landed in PR #12941 and its server-side consumption wiring in PR #13009; this PR lands the queue half. The comment surface is untouched — it stays gated on Drew's answer to design question 4 on #1253, as scoped on the issue.Behavior
POST /api/actions(and per-item inPOST /api/actions/batch), when the Access author enforcer refuses with 401 (identity verification failed — the outage signal), the write is queued instead of refused only if the peer address is stack-local (loopback / tailnet CGNAT 100.64/10 / private ranges; the aggregator's only listeners, checked fail-closed) and the write is eligible. A 403 — a verified identity contradicting the claim — is not an outage and never queues. Every other refusal is byte-identical to before.dreworagent), except the four preference view verbs the aggregator applies synchronously itself (save-view/rename-view/delete-view/set-default-view), which fail closed — a queue cannot honour their applied-in-request contract. Amuseclaim can never be confirmed by an Access derivation, so it fails closed rather than stranding in the queue.OutageQueueStore(src/outage-queue.ts; fresh disk reads, serialized mutations, atomic persist — the break-glass store pattern) holds them stampedprovenance: outage-queuedwith the claimed author kept visibly a claim. They never enter the actions store, so consumer polls (GET /api/actions.json?state=new) never see them. Queueing writes anoutage-write-queuedaudit event before the record persists (audit failure ⇒ nothing queues), dedupes by clientToken like the actions store, and answers202 {queued: true, provenance: "outage-queued", queue: <record>}.POST /api/actions/outage-queue/confirm {id}requires the enforcer to succeed with a verified identity whose derived author matches the claim (kind + id); the published-item checks re-run (the item may have changed while queued), the write is released into the actions store under the verified author (the re-stamp), anoutage-write-confirmedaudit event lands, and only then is the record marked confirmed with the released action id.POST /api/actions/outage-queue/reject {id}is the same gate marking the record rejected with anoutage-write-rejectedaudit event. One recorded judgment call: a verified owner may reject a claim that is not theirs (rejection can never create authorship; without it a forged claim could never be cleared from the owner's own queue). Confirmation stays claimant-only, strictly. Nothing is ever auto-promoted.GET /api/actions/outage-queue.json(optional?state=) is the queue's only read surface. Config:outageQueueFileviaPM_AGG_OUTAGE_QUEUE_FILE, default~/.local/state/pm-aggregator/outage-queue.json(the break-glass state-dir precedent). The peer address is threaded fromBun.serve(server.requestIP) throughfetchHandlerintohandleras an optional parameter; no other route changes.Evidence
Remote dispatch only (fleet-command workflow on developing-today/fleet; the primary
fleet queue dispatchhit the known TLS UnknownIssuer error, so the documented workflow fallback was used; bun is bootstrapped inside the command because the runner image has none):~/.local/state/pm-aggregator/at startup and that directory does not exist in the clean runner, so every boot suite fails there identically, including the pre-existingactions.test.tsandbreak-glass-route-9608.test.tson code this PR does not change. My route suite now pointsPM_METADATA_DB_PATHat its temp dir and boots cleanly in both venues.outage-queue.test.ts(11: stamping, audit-before-persist, audit-failure fail-closed, clientToken dedupe, eligibility, stack-local table, confirm-under-verified-author, mismatch 403, release-failure stays queued, rejection claimant/owner/stranger),outage-queue-route-9608.test.ts(4: 202 + held out of the actions store on disk and via API, ineligible 401s, batch per-item queueing, confirm/reject refuse without a fresh login),break-glass.test.ts,access-identity.test.ts,config.test.ts(incl. the new field's default/env coverage).bunx tsc --noEmitexit 0 over the whole aggregator.actions.test.tsandbreak-glass-route-9608.test.ts(boot-crash there for the pre-existing reason above; both pass on the laptop per the feat(pm-stack): break-glass owner token — local CLI, audit-first issuance (#9608) #12941/feat(pm-aggregator): wire break-glass token consumption into the identity-registry gate (#9608) #13009 records, and this PR's only shared-surface change is the optionalremoteAddresshandler parameter plus additive routes — typecheck covers the wiring).Merge danger
Low-moderate. With Access unconfigured, behaviour is byte-identical (the enforcer never refuses, so the queue path is unreachable). With Access configured, the only changed responses are the new 202 queueing path under the triple gate (401 + stack-local + eligible) and the three new routes; all existing refusals and success paths are unchanged. The queue store file is created only when a write actually queues. No new dependencies; no schedules created, changed, or retired.
Refs #9608 — the issue stays open for the #1253 question-4-gated comment surface only.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.